#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QTcpSocket>
#include "register.h"
#include "courier.h"
#include "consignee.h"
#include "courier_main.h"
#include "courier_add.h"
#include "consignee_main.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
//用户标志保存
QString telephone_number;

//单例模式下的套接字构造与连接
class SocketManager : public QObject {
    Q_OBJECT
public:
    static SocketManager& getinstance() {
        static SocketManager instance;
        return instance;
    }
    SocketManager(const SocketManager&) = delete ;
    SocketManager& operator=(const SocketManager&) = delete ;
    QTcpSocket * socket(){
        return m_socket;
    }
private:
    explicit SocketManager(QObject *parent = nullptr):QObject(parent){
        m_socket->connectToHost("192.168.6.42",8888);
    }
    ~SocketManager(){}
    QTcpSocket * m_socket;
};
//主窗口
class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void connect_client();
    void page1_init();

private slots:
    void start();

    void rgttomain();
    void on_pushButton_3_clicked();
    void returnRegister();
    void registertocourier();
    void couriertomain();
    void rgttoconsignee();
    void consigneeToRegister();
    void on_pushButton_2_clicked();

private:
    Ui::MainWindow *ui;

    Register *register_page;
    Courier * courier_page;
    Consignee * consignee_page;
    Courier_main * courier_main_page;
    Courier_add * courier_add_page;
    Consignee_main * consignee_main_page;
    QTcpSocket *socket;
    bool connectstate;
};


struct sendRig{
    int type;
    char Account[64];
    char password[24];
    bool Idtype;
    char tele[24];
    int IC;
    char teletwo[24];
    char state[24];
    char ID[24];
};
#endif // MAINWINDOW_H
